package com.example.sparksqltest.demos.config;

import org.apache.spark.sql.SparkSession;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Configuration
public class SparkConfig {

    private static final Logger logger = LoggerFactory.getLogger(SparkConfig.class);

    @Bean
    public SparkSession createSparkSession() {
        logger.info("正在创建SparkSession...");
        SparkSession sparkSession = SparkSession.builder()
                .appName("SparkSQL")
                .master("local[*]")
                .getOrCreate();
        logger.info("SparkSession创建成功。");
        return sparkSession;
    }
}
